<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>图片外链</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="Author" content="larry" />
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black">
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">
  <link rel="Shortcut Icon" href="/favicon.ico" />
  <link rel="stylesheet" type="text/css" href="/static/admin/common/layui/css/layui.css" media="all">
  <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/base.css" media="all">
  <link rel="stylesheet" type="text/css" href="/static/admin/common/css/animate.css" media="all">
  <link rel="stylesheet" type="text/css" href="/static/admin/backstage/css/admin.css" media="all">
</head>
<body>
<div class="layui-fluid">
  <div class="larry-container larryms-admin">
    <div class="layui-row layui-col-space20">
      <div class="layui-col-xs12 animated fadeInRightBig">
        <section class="larry-panel">

          <div class="larryms-page-header">
            <span class="tit">图片外链</span>
          </div>
          <div class="larryms-page-body">
              <div class="layui-form-item">
                <form class="layui-form" enctype="multipart/form-data" name="form1">
                  <div class="layui-upload">
                    <button type="button" class="layui-btn" id="test1">上传图片</button>
                    <div class="layui-upload-list">
                      <img class="layui-upload-img" id="demo1" name="file" width="200">
                      <p id="demoText"></p>
                    </div>
                  </div>
                  <div class="layui-tab" style="display: none" id="content">
                    <ul class="layui-tab-title">
                      <li class="layui-this">URL</li>
                      <li>HTML</li>
                      <li>BBCode</li>
                      <li>Markdown</li>
                      <li>Markdown with Link</li>
                      <li>Delete Link</li>
                    </ul>
                    <div class="layui-tab-content">
                      <div class="layui-tab-item layui-show">
                        <blockquote class="layui-elem-quote" id="url"></blockquote>
                      </div>
                      <div class="layui-tab-item">
                        <blockquote class="layui-elem-quote" id="html"></blockquote>
                      </div>
                      <div class="layui-tab-item">
                        <blockquote class="layui-elem-quote" id="bbcode"></blockquote>
                      </div>

                      <div class="layui-tab-item">
                        <blockquote class="layui-elem-quote" id="markdown"></blockquote>
                      </div>
                      <div class="layui-tab-item">
                        <blockquote class="layui-elem-quote" id="markdown_with_link"></blockquote>
                      </div>
                      <div class="layui-tab-item">
                        <blockquote class="layui-elem-quote" id="delete_link"></blockquote>
                      </div>
                    </div>
                  </div>
                </form>
              </div>
              <div class="layui-form-item">
                <div class="layui-input-block">
                  <div id="a1"></div>
                </div>
              </div>
          </div>
        </section>
      </div>
    </div>
  </div>
</div>
<!-- 加载js文件-->
<script type="text/javascript" src="/static/admin/common/layui/layui.js"></script>
<script type="text/javascript" src="/static/admin/my/js/ckplayer.js"></script>




<script>
    layui.use(['element','form', 'layer','upload'], function(){
        var element = layui.element;
        var form = layui.form;
        var $ = layui.$ //重点处
            ,layer = layui.layer
            ,upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            ,url: "{:url('/admin/tool/pic_uploads')}"
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            ,done: function(res){
                if(res.code == '1'){
                    layer.msg(res.msg, {icon: 6});
                    $("#content").show();

                    $('#url').html(res.data.url + "\n");
                    $('#html').html("&lt;img src=\""+ res.data.url +"\" alt=\""+ res.data.storename +"\" title=\""+ res.data.storename +"\" /&gt;" + "\n");
                    // $('#html').html("&lt;img src=\""+ res.data.url +"\" alt=\""+ res.data.storename +"\" title=\""+ res.data.storename +"\" /&gt;" + "\n");
                    $('#bbcode').html("[img]"+ res.data.url +"[/img]" + "\n");
                    $('#markdown').html("!["+ res.data.storename +"](" + res.data.url + ")" + "\n");
                    $('#markdown_with_link').html("[!["+ res.data.storename +"](" + res.data.url + ")]" +"(" + res.data.url + ")" + "\n");
                    $('#delete_link').html(res.data.delete + "\n");

                }else{
                    layer.msg(res.msg, {icon: 5});
                }
            }

        });
    })
</script>
</body>
</html>




